package com.iretailer.report.model.enums;

/**
 * @program: report
 * @description:
 * @author: Bennie
 * @create: 2020-07-02 08:59
 **/

public interface BaseEnum {

    String getName();

    static <T> T  getByName(String name,Class<T> aClass) {
       if(aClass.isAssignableFrom(BaseEnum.class) && aClass.isEnum()){

           T[] ts = aClass.getEnumConstants();
           for (T t : ts) {
               BaseEnum baseEnum = (BaseEnum)t;
               if(baseEnum.getName().equals(name)){
                   return t;
               }
           }
       }
       return null;
    }

}
